Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Basics. How to use <a href> equivalent to display new content?
Forum Updated to NodeBB v4.3 + New Features

Basics. How to use <a href> equivalent to display new content?

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 3 Posters 6.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Andrey VolodinA Offline
    Andrey VolodinA Offline
    Andrey Volodin
    wrote on last edited by Andrey Volodin
    #1

    Dear all,

    I do create a widget with mainwindow ui.
    I want it to open a different ui on a link press as does internet browser do on a hyperlink press. New content of a window is supposed to have different buttons set and different background image &c.
    So far I have found an instruction on that : http://stackoverflow.com/questions/5064815/launching-new-form-by-a-button-click-in-qt-gui-application
    I have added a second ui form to the project.

    ![http://imgur.com/a/XKN8H](image url)
    screenshoot

    And in the first ui file I added a button, and I want to display a new content in the same window on buttonpress event. And I addd the second .ui for that.

    But it turned out that the button at mainwindow .ui doesn't know about second.ui as a receiver.

    http://imgur.com/e3YBfmP.

    How to get navigation there?
    To browse content in a window like in an internet browser.

    Basically, I wanted an element appeared on buttonpress.

    But it turned out that all added to a form elements appear at once.

    I decided that use of ui files as html equivalent could be used to reflect new window content.

    May be there is an attribute for elements like "not to display on run, but only on event"?

    ---//--
    perhaps I should try the way described there
    http://www.qtcentre.org/threads/65390-Navigation-between-windows
    ----//--
    is there a way to convert element CentralWidget to stacketWidget?
    is there is a way to add few central widget elements?
    But the "Receiver" list still doesnt reflect page1 page2 of stackwidget to determine which page to display. It has the general stackWidget entry only.
    How to address its subsections?
    How to bind its subsections to a button press or to something?
    haha,I found arrows.
    Is there a chance to use buttonpress instead?

    jsulmJ 1 Reply Last reply
    0
    • Andrey VolodinA Andrey Volodin

      Dear all,

      I do create a widget with mainwindow ui.
      I want it to open a different ui on a link press as does internet browser do on a hyperlink press. New content of a window is supposed to have different buttons set and different background image &c.
      So far I have found an instruction on that : http://stackoverflow.com/questions/5064815/launching-new-form-by-a-button-click-in-qt-gui-application
      I have added a second ui form to the project.

      ![http://imgur.com/a/XKN8H](image url)
      screenshoot

      And in the first ui file I added a button, and I want to display a new content in the same window on buttonpress event. And I addd the second .ui for that.

      But it turned out that the button at mainwindow .ui doesn't know about second.ui as a receiver.

      http://imgur.com/e3YBfmP.

      How to get navigation there?
      To browse content in a window like in an internet browser.

      Basically, I wanted an element appeared on buttonpress.

      But it turned out that all added to a form elements appear at once.

      I decided that use of ui files as html equivalent could be used to reflect new window content.

      May be there is an attribute for elements like "not to display on run, but only on event"?

      ---//--
      perhaps I should try the way described there
      http://www.qtcentre.org/threads/65390-Navigation-between-windows
      ----//--
      is there a way to convert element CentralWidget to stacketWidget?
      is there is a way to add few central widget elements?
      But the "Receiver" list still doesnt reflect page1 page2 of stackwidget to determine which page to display. It has the general stackWidget entry only.
      How to address its subsections?
      How to bind its subsections to a button press or to something?
      haha,I found arrows.
      Is there a chance to use buttonpress instead?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Andrey-Volodin Sounds like you could use http://doc.qt.io/qt-5/qstackedwidget.html for this

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Andrey VolodinA Offline
        Andrey VolodinA Offline
        Andrey Volodin
        wrote on last edited by Andrey Volodin
        #3

        thank you for your reply.
        It seems that the stackwidgets have two arrows next+back
        is there a chance to use button push or customize arrows somwhow from GUI?
        is there a way to get navigation on sides of 3D cube which rotates on touch and each side of which represent .ui or a form or an interface or a page?

        the_T jsulmJ 2 Replies Last reply
        0
        • Andrey VolodinA Andrey Volodin

          thank you for your reply.
          It seems that the stackwidgets have two arrows next+back
          is there a chance to use button push or customize arrows somwhow from GUI?
          is there a way to get navigation on sides of 3D cube which rotates on touch and each side of which represent .ui or a form or an interface or a page?

          the_T Offline
          the_T Offline
          the_
          wrote on last edited by
          #4

          @Andrey-Volodin

          No, QStackedWidget does not have native arrow buttons to navigate.

          But you may see some kind of buttons in the QtDesigner to switch between the pages for creating them.

          -- No support in PM --

          1 Reply Last reply
          1
          • Andrey VolodinA Andrey Volodin

            thank you for your reply.
            It seems that the stackwidgets have two arrows next+back
            is there a chance to use button push or customize arrows somwhow from GUI?
            is there a way to get navigation on sides of 3D cube which rotates on touch and each side of which represent .ui or a form or an interface or a page?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Andrey-Volodin said in Basics. How to use <a href> equivalent to display new content?:

            It seems that the stackwidgets have two arrows next+back

            No, QStackedWidget itself has no arrows. What you mean is probably what you see in Designer, but it's only in Designer.

            "is there a chance to use button push or customize arrows somwhow from GUI?" - sure, you can use what ever you want. Please read documentation, there is an example:

            QComboBox *pageComboBox = new QComboBox;
                pageComboBox->addItem(tr("Page 1"));
                pageComboBox->addItem(tr("Page 2"));
                pageComboBox->addItem(tr("Page 3"));
                connect(pageComboBox, SIGNAL(activated(int)),
                        stackedWidget, SLOT(setCurrentIndex(int)));
            

            This example is using QComboBox, but you can use QPushButton and setCurrentIndex(int) slot.

            "is there a way to get navigation on sides of 3D cube which rotates on touch and each side of which represent .ui or a form or an interface or a page?" - yes, but this is something you need to implement.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • Andrey VolodinA Offline
              Andrey VolodinA Offline
              Andrey Volodin
              wrote on last edited by Andrey Volodin
              #6

              no, it wont change pages with Combo Box http://imgur.com/kkudCQI
              though of 9 comboboxes one now changes page

              the_T 1 Reply Last reply
              0
              • Andrey VolodinA Andrey Volodin

                no, it wont change pages with Combo Box http://imgur.com/kkudCQI
                though of 9 comboboxes one now changes page

                the_T Offline
                the_T Offline
                the_
                wrote on last edited by
                #7

                @Andrey-Volodin

                What exactly did you try? This screenshot does not help much as it is the Designer View...

                -- No support in PM --

                1 Reply Last reply
                0
                • Andrey VolodinA Offline
                  Andrey VolodinA Offline
                  Andrey Volodin
                  wrote on last edited by Andrey Volodin
                  #8

                  shall I refrain from using of Qt Designer in favor of text editor?
                  https://pastebin.com/x9qLmd6z

                  1 Reply Last reply
                  0
                  • Andrey VolodinA Offline
                    Andrey VolodinA Offline
                    Andrey Volodin
                    wrote on last edited by
                    #9

                    to where should I paste the fragment:
                    QComboBox *pageComboBox = new QComboBox;
                    pageComboBox->addItem(tr("Page 1"));
                    pageComboBox->addItem(tr("Page 2"));
                    pageComboBox->addItem(tr("Page 3"));
                    connect(pageComboBox, SIGNAL(activated(int)),
                    stackedWidget, SLOT(setCurrentIndex(int)));
                    ?

                    jsulmJ 1 Reply Last reply
                    0
                    • Andrey VolodinA Andrey Volodin

                      to where should I paste the fragment:
                      QComboBox *pageComboBox = new QComboBox;
                      pageComboBox->addItem(tr("Page 1"));
                      pageComboBox->addItem(tr("Page 2"));
                      pageComboBox->addItem(tr("Page 3"));
                      connect(pageComboBox, SIGNAL(activated(int)),
                      stackedWidget, SLOT(setCurrentIndex(int)));
                      ?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Andrey-Volodin Depends on where you have this stacked widget. If it is in main window, then in mainwindow constructor. If you're using Designer then no need to use this code snippet: add the combo box in designer and connect signal and slot in Designer.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • Andrey VolodinA Offline
                        Andrey VolodinA Offline
                        Andrey Volodin
                        wrote on last edited by
                        #11

                        thank you for your reply
                        it is getting working and now it works finally with the combobox

                        1 Reply Last reply
                        0
                        • Andrey VolodinA Offline
                          Andrey VolodinA Offline
                          Andrey Volodin
                          wrote on last edited by
                          #12
                          QPushButton and setCurrentIndex(int) slot.
                          

                          No, I can not use the above. The mainwindow constructor which seems to be a designer doesn't seem to have that option in a list for a pushbutton item.

                          jsulmJ 1 Reply Last reply
                          0
                          • Andrey VolodinA Andrey Volodin
                            QPushButton and setCurrentIndex(int) slot.
                            

                            No, I can not use the above. The mainwindow constructor which seems to be a designer doesn't seem to have that option in a list for a pushbutton item.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by jsulm
                            #13

                            @Andrey-Volodin Well, setCurrentIndex(int) needs a parameter, so you cannot connect the push button directly. But you can add a slot in main window, connect it to the push button and in this slot call setCurrentIndex(int).

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            1
                            • Andrey VolodinA Offline
                              Andrey VolodinA Offline
                              Andrey Volodin
                              wrote on last edited by Andrey Volodin
                              #14

                              https://github.com/AndreV84/pilot
                              it seems that there should be 4 objects defined:
                              button , the main window, stack widget , as in
                              http://doc.qt.io/qt-4.8/signalsandslots.html
                              how to add trigger? comparator? logical + or -?

                              jsulmJ 1 Reply Last reply
                              0
                              • Andrey VolodinA Andrey Volodin

                                https://github.com/AndreV84/pilot
                                it seems that there should be 4 objects defined:
                                button , the main window, stack widget , as in
                                http://doc.qt.io/qt-4.8/signalsandslots.html
                                how to add trigger? comparator? logical + or -?

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                @Andrey-Volodin said in Basics. How to use <a href> equivalent to display new content?:

                                how to add trigger

                                What trigger do you mean?

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • Andrey VolodinA Offline
                                  Andrey VolodinA Offline
                                  Andrey Volodin
                                  wrote on last edited by Andrey Volodin
                                  #16

                                  on button press a call is passed to a slot

                                  how to make the slot to change stackWidget page on the button press

                                  https://en.wikipedia.org/wiki/Event-driven_programming
                                  https://en.wikipedia.org/wiki/Schmitt_trigger
                                  it seems that the button and the stackwidget are always in separate sets, despite a new slot and a new signal created

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • Andrey VolodinA Andrey Volodin

                                    on button press a call is passed to a slot

                                    how to make the slot to change stackWidget page on the button press

                                    https://en.wikipedia.org/wiki/Event-driven_programming
                                    https://en.wikipedia.org/wiki/Schmitt_trigger
                                    it seems that the button and the stackwidget are always in separate sets, despite a new slot and a new signal created

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by jsulm
                                    #17

                                    @Andrey-Volodin Not sure I understand the problem. Did you read http://doc.qt.io/qt-5.8/signalsandslots.html ?
                                    You just define a slot in lets say MainWindow:

                                    // Header
                                    class MainWindow:
                                    {
                                    private slots:
                                        void onButtonPressed();
                                    };
                                    
                                    // cpp
                                    MainWindow::MainWindow()
                                    {
                                        connect(ui->pushButton, SIGNAL(clicked(bool)), this, SLOT(onButtonPressed()));
                                    }
                                    
                                    void MainWindow::onButtonPressed()
                                    {
                                        int pageToShow = 1; // you need to find out what the next index is
                                        ui->stackedWidget->setCurrentIndex(pageToShow);
                                    }
                                    

                                    "it seems that the button and the stackwidget are always in separate sets, despite a new slot and a new signal created" - sorry, I don't understand. What do you mean by "sets"?

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    0
                                    • Andrey VolodinA Offline
                                      Andrey VolodinA Offline
                                      Andrey Volodin
                                      wrote on last edited by Andrey Volodin
                                      #18

                                      https://en.wikipedia.org/wiki/Set_(mathematics)
                                      I used to read: http://doc.qt.io/qt-4.8/signalsandslots.html , which seems to be a mirror of the link http://doc.qt.io/qt-5.8/signalsandslots.html .
                                      I tried to perform the task in Designer, without sources editing manually. It doesnt appear to seem possible.

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • Andrey VolodinA Andrey Volodin

                                        https://en.wikipedia.org/wiki/Set_(mathematics)
                                        I used to read: http://doc.qt.io/qt-4.8/signalsandslots.html , which seems to be a mirror of the link http://doc.qt.io/qt-5.8/signalsandslots.html .
                                        I tried to perform the task in Designer, without sources editing manually. It doesnt appear to seem possible.

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #19

                                        @Andrey-Volodin
                                        https://en.wikipedia.org/wiki/Set_(mathematics) - still don't understand what you mean with sets in this particular context.
                                        In designer you can connect existing signals/slots. You can even define a new slot in Designer, but you have to implement it by yourself.
                                        That means: add slot to main window in Designer, connect this slot to the clicked() signal of your push button in Designer, implement the slot in main window.

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        Andrey VolodinA 1 Reply Last reply
                                        0
                                        • jsulmJ jsulm

                                          @Andrey-Volodin
                                          https://en.wikipedia.org/wiki/Set_(mathematics) - still don't understand what you mean with sets in this particular context.
                                          In designer you can connect existing signals/slots. You can even define a new slot in Designer, but you have to implement it by yourself.
                                          That means: add slot to main window in Designer, connect this slot to the clicked() signal of your push button in Designer, implement the slot in main window.

                                          Andrey VolodinA Offline
                                          Andrey VolodinA Offline
                                          Andrey Volodin
                                          wrote on last edited by Andrey Volodin
                                          #20

                                          @jsulm said in Basics. How to use <a href> equivalent to display new content?:

                                          In designer you can connect existing signals/slots. You can even define a new slot in Designer, but you have to implement it by yourself.
                                          That means: add slot to main window in Designer, connect this slot to the clicked() signal of your push button in Designer, implement the slot in main window.

                                          The above is what I have done ;
                                          How to connect the stackWidgets call with the above?
                                          What do you mean saying "implement the slot in mine window" ?

                                          jsulmJ 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved